]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/backlight: Do only one dbus call per local change
authorBarnabás Pőcze <pobrn@protonmail.com>
Tue, 16 Jan 2024 22:41:24 +0000 (23:41 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 16 Jan 2024 23:30:42 +0000 (23:30 +0000)
The values of the two control widgets are syncronized, meaning
that both emit signals when the local value changes, regardless
which one is visible and is actually used by the user.

This is not ideal because it leads to two dbus calls
per local change. To alleviate this, only consider
changes from the widget that is visible.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3086>

js/ui/status/backlight.js

index ca901d547869fd00be4ae0f02436e57e5f635b9e..686ed3361c358ff2781a118e38895f3c118a4f7b 100644 (file)
@@ -177,11 +177,15 @@ class KeyboardBrightnessToggle extends QuickMenuToggle {
             this._discreteItem, 'value',
             GObject.BindingFlags.SYNC_CREATE);
 
-        this._sliderItemChangedId = this._sliderItem.connect('notify::value',
-            () => (this._proxy.Brightness = this._sliderItem.value));
+        this._sliderItemChangedId = this._sliderItem.connect('notify::value', () => {
+            if (this._sliderItem.visible)
+                this._proxy.Brightness = this._sliderItem.value;
+        });
 
-        this._discreteItemChangedId = this._discreteItem.connect('notify::value',
-            () => (this._proxy.Brightness = this._discreteItem.value));
+        this._discreteItemChangedId = this._discreteItem.connect('notify::value', () => {
+            if (this._discreteItem.visible)
+                this._proxy.Brightness = this._discreteItem.value;
+        });
     }
 
     _sync() {